package com.kelvem.saas.workbanch.ontology.order.handle.confirm;

import com.kelvem.saas.workbanch.fsm.entity.Entity;
import com.kelvem.saas.workbanch.fsm.core.EventContext;
import com.kelvem.saas.workbanch.fsm.handle.Handle;
import com.kelvem.saas.workbanch.fsm.container.FsmContainer;
import com.kelvem.saas.workbanch.ontology.order.enums.OrderEventEnum;
import com.kelvem.saas.workbanch.ontology.order.model.OrdersEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author kelvem
 */
@Service
@Slf4j
public class AutoConfirmOrderHandler extends Handle {
    
    @Override
    public void execute() {
        
        OrdersEntity order = Entity.instance().selectOne(OrdersEntity.class);
    
        FsmContainer.triggerEvent(OrdersEntity.class, OrderEventEnum.order_confirm.getEventCode(), order);
    
        log.info("Handle[" + getName() + "] order=" + order);
        EventContext.print();
    }
}
